package com.itcoon.cloud.framework.transform.handler;/**
 * @author Athric Yu
 * 2024/9/30
 **/

import com.itcoon.cloud.framework.transform.TransformHandler;
import com.itcoon.cloud.framework.transform.TransformHandlerFactory;
import com.itcoon.cloud.framework.transform.config.TransformConfigurationProperties;

import java.util.HashMap;
import java.util.Map;

/**
 *
 *
 * @author Athric Yu
 * 2024/9/30
 **/
public class TransformHandlerFactoryImpl implements TransformHandlerFactory {

    private static final Map<Class<?>, TransformHandler<?, ?>> TRANSFORM_HANDLER_CACHE = new HashMap<>();

    private final TransformConfigurationProperties properties;

    public TransformHandlerFactoryImpl(TransformConfigurationProperties properties) {
        this.properties = properties;
    }

    @Override
    public <T, R> TransformHandler<T, R> getTransformHandler(Class<R> targetType) {
        return targetType.isInterface() ? InterfaceTransformHandler.getInstance(properties) : ClazzTransformHandler.<T, R>getInstance(properties);
    }



}
